
<?php

class CExtensionesTable
{

public static $instance; 



 function DrawTable($title,$table,$growtable,$campos)//obligatorio ID como campo inicial
    {
    $qu="select ";
    $i = 0;
    foreach($campos as $id=>$valor)
    {
    $qu=$qu."$id,";

    }
    $qu=substr($qu,0,strlen($qu)-1);
  
    
    $qu=$qu." from extensiones";
    

     echo "<div id='content_area_user_title'>";
    echo "<h2> $title</h2>";
    echo "</div>";


    echo	"<form>";						
    echo "<form id='filter-form'>Filtrar operador: <input name='filter' id='filter' value='' maxlength='30' size='30' type='text'></form><br>";
    echo "</form>";
   
    echo "<div class='usersettings_statistics'>"; 
 


    echo "<table class='food_planner'>";
    
        echo "<thead>";
        echo "<tr>";
        //$width=10;    
        foreach($campos as $id=>$valor){
    
        echo "<th>$valor</th>";
        //$width=$width+10;
        }
        echo "</tr>";    
        echo "</thead>";
     
    
    
    echo "<tbody><tr style='display: table-row;'>";

     //echo "<table> <tbody>";
 echo "<tr class='odd'>";
 
    
    // $qu="select*from $table";
    $table=CModelo::getInstance()->getData($qu);
//var_dump($table);
    $cont=0;
    $ruta=CConfig::getInstance()->rutalocal;
    
    
    foreach($table as $campo => $valor)
    { 



$cont=$cont+1;
if($cont%2){




echo "<tr class='odd'>";
$i="";$cont=0;
foreach($valor as $id=>$val)
{ if($cont==0){$i=$val;}
 if($cont==2){
  $que = "select NamOpe from operador where idOpe = $val";

  $NamOpe = CModelo::getInstance()->getData($que);

    foreach($NamOpe as $q=>$w){
    $tab=$w;
    foreach($tab as $q2=>$w2){
        $val = $w2;
    }
    
    }}

echo "<td>$val</td>";$cont=$cont+1;
}
/*---------------------------------------------------------------------------*/
// las referencias debbden de ser modificadas deacuerdo al directorio
//
/*---------------------------------------------------------------------------*/



//echo "<t  d> <a href='$ruta/MDTourGeneral/CTourEdit.php?codigo=$i'>$numpaxa[0]</a>  </td>";


//echo "<td> <input type=button onClick=\"parent.location='$ruta/MDItinerary/MDEItinerary.php?codigo=$i'\" value='Buscar tour'>  </td>";
echo "<td> <a href='$ruta/MDTourGeneral/CTourEdit.php?codigo=$i'> <img src='../images/edit.png' width='32' title='Editar extensión $i'/></a> </td>";
echo "<td><a href='/christian1/modificar.php?codigo=$i'> <img src='../images/trash.png' width='32' title='Eliminar extensión $i'/> </a> </td>";
echo "</tr>";
}
else
{

echo "<tr class='even'> ";
$i2="";$cont2=0;
foreach($valor as $id => $val)
{ if($cont2==0){$i2=$val;}
if($cont2==2){
  $que = "select NamOpe from operador where idOpe = $val";

  $NamOpe = CModelo::getInstance()->getData($que);

    foreach($NamOpe as $q=>$w){
    $tab=$w;
    foreach($tab as $q2=>$w2){
        $val = $w2;
    }
    
    }}
echo "<td>$val </td>";$cont2=$cont2+1;
}

//echo "<td> <input type=button onClick=\"parent.location='$ruta/MDItinerary/MDEItinerary.php?codigo=$i2'\" value='Buscar tours'>  </td>";
echo "<td> <a href='$ruta/MDTourGeneral/CTourEdit.php?codigo=$i2'> <img src='../images/edit.png' width='32' title='Editar extensión $i2'/> </a> </td>";
echo "<td><a href='/christian1/modificar.php?codigo=$i2'>  <img src='../images/trash.png' width='32' title='Eliminar extensión $i2'/> </a> </td>";
echo "</tr>";
}

}
echo "</td></tr></tbody></table><br><br></form>";


echo "</div>";

} 


public static function getInstance()
	{
		//echo "<div id=register-box>";
        if(self::$instance==null)
		  self::$instance=new CExtensionesTable();
	//   echo "</div>";	  
		return  self::$instance;
	   
    
    }	


}
?>